"use strict";
cc._RF.push(module, 'd1bfa7f7iJNcaq6HV/cz1cP', 'SettingsUI');
// scripts/SettingsUI.js

"use strict";

var t = require;
var e = module;
var o = exports;

var _n21,
    i = void 0 && (void 0).__extends || (_n21 = function n(t, e) {
  return (_n21 = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _n21(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
}),
    s = void 0 && (void 0).__decorate || function (t, e, o, n) {
  var i,
      s = arguments.length,
      r = s < 3 ? e : null === n ? n = Object.getOwnPropertyDescriptor(e, o) : n;
  if ("object" == (typeof Reflect === "undefined" ? "undefined" : typeof Reflect) && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, n);else for (var c = t.length - 1; c >= 0; c--) {
    (i = t[c]) && (r = (s < 3 ? i(r) : s > 3 ? i(e, o, r) : i(e, o)) || r);
  }
  return s > 3 && r && Object.defineProperty(e, o, r), r;
};

Object.defineProperty(o, "__esModule", {
  value: !0
});

var r = t("Common"),
    c = t("Global"),
    a = t("BaseUI"),
    u = t("UIEnum"),
    l = t("UIManager"),
    d = t("SDK"),
    p = cc._decorator,
    h = p.ccclass,
    f = p.property,
    g = function (t) {
  function e() {
    var e = null !== t && t.apply(this, arguments) || this;
    return e.childNode = null, e.closeBtn = null, e.musicBtn = null, e.soundBtn = null, e.shockBtn = null, e.game = null, e.status = 1, e.time = 0.2, e;
  }

  return i(e, t), e.prototype.onLoad = function () {
    var t = this,
        e = this;
    this.musicBtn.on(cc.Node.EventType.TOUCH_END, function (e) {
      1 == c["default"].settings.music ? (c["default"].settings.music = 0, t.musicBtn.getChildByName("open").active = !1, t.musicBtn.getChildByName("close").active = !0, r["default"].stopMucis()) : (c["default"].settings.music = 1, t.musicBtn.getChildByName("open").active = !0, t.musicBtn.getChildByName("close").active = !1, r["default"].playMusic(t.game.bgmMusic, !0)), t.saveSettings(), e.stopPropagation();
    }, this), this.soundBtn.on(cc.Node.EventType.TOUCH_END, function (e) {
      1 == c["default"].settings.sound ? (c["default"].settings.sound = 0, r["default"]._soundOpen = 0, t.soundBtn.getChildByName("open").active = !1, t.soundBtn.getChildByName("close").active = !0) : (c["default"].settings.sound = 1, r["default"]._soundOpen = 1, t.soundBtn.getChildByName("open").active = !0, t.soundBtn.getChildByName("close").active = !1), t.saveSettings(), e.stopPropagation();
    }, this), this.shockBtn.on(cc.Node.EventType.TOUCH_END, function (e) {
      1 == c["default"].settings.shock ? (c["default"].settings.shock = 0, r["default"]._shockOpen = 0, t.shockBtn.getChildByName("open").active = !1, t.shockBtn.getChildByName("close").active = !0) : (r["default"]._shockOpen = 1, c["default"].settings.shock = 1, t.shockBtn.getChildByName("open").active = !0, t.shockBtn.getChildByName("close").active = !1), t.saveSettings(), e.stopPropagation();
    }, this), this.closeBtn.on(cc.Node.EventType.TOUCH_END, function (t) {
      e.hide(), t.stopPropagation();
    }, this);
  }, e.prototype.init = function (t) {
    this.game = t, 1 == c["default"].settings.music ? (this.musicBtn.getChildByName("open").active = !0, this.musicBtn.getChildByName("close").active = !1) : (this.musicBtn.getChildByName("open").active = !1, this.musicBtn.getChildByName("close").active = !0), 1 == c["default"].settings.sound ? (this.soundBtn.getChildByName("open").active = !0, this.soundBtn.getChildByName("close").active = !1, r["default"]._soundOpen = 1) : (this.soundBtn.getChildByName("open").active = !1, this.soundBtn.getChildByName("close").active = !0, r["default"]._soundOpen = 0), 1 == c["default"].settings.shock ? (r["default"]._shockOpen = 1, this.shockBtn.getChildByName("open").active = !0, this.shockBtn.getChildByName("close").active = !1) : (r["default"]._shockOpen = 0, this.shockBtn.getChildByName("open").active = !1, this.shockBtn.getChildByName("close").active = !0);
  }, e.prototype.backHome = function () {
    this.game.backHome(), this.hide();
  }, e.prototype.saveSettings = function () {
    d["default"].setLocalStorage("settings", JSON.stringify(c["default"].settings));
  }, e.prototype.start = function () {}, e.prototype.hide = function () {
    l.UIMgr.hide(u["default"].SettingsUI, !1, !0);
  }, e.prototype.onShow = function () {
    this.node.active = !0, this.childNode.scale = 0, cc.tween(this.childNode).to(0.3, {
      scale: 1
    }).call(function () {}).start();
  }, e.prototype.onEnable = function () {
    this.status = 0, d["default"].isTT() && d["default"].showBanner();
  }, e.prototype.onDisable = function () {
    this.status = 1, d["default"].isTT() && d["default"].hideBanner();
  }, e.prototype.update = function () {}, s([f(cc.Node)], e.prototype, "childNode", void 0), s([f(cc.Node)], e.prototype, "closeBtn", void 0), s([f(cc.Node)], e.prototype, "musicBtn", void 0), s([f(cc.Node)], e.prototype, "soundBtn", void 0), s([f(cc.Node)], e.prototype, "shockBtn", void 0), s([h], e);
}(a["default"]);

o["default"] = g;

cc._RF.pop();